import dayjs from "dayjs";

/**
 * 优惠类型枚举
 */
export enum PromotionDiscountTypeEnum {
  PRICE = 1,
  PERCENT = 2
}

/**
 * 优惠劵模板的有限期类型的枚举
 */
export enum CouponTemplateValidityTypeEnum {
  DATE = 1,
  TERM = 2
}

/**
 * 营销的商品范围枚举
 */
export enum PromotionProductScopeEnum {
  ALL = 1,
  SPU = 2,
  CATEGORY = 3
}

// 时间段的状态枚举
export enum TimeStatusEnum {
  WAIT_START = '即将开始',
  STARTED = '进行中',
  END = '已结束',
}

export const getTimeStatusEnum = (startTime: dayjs.ConfigType, endTime: dayjs.ConfigType): TimeStatusEnum => {
  const now = dayjs();
  if (now.isBefore(startTime)) {
    return TimeStatusEnum.WAIT_START;
  } else if (now.isAfter(endTime)) {
    return TimeStatusEnum.END;
  } else {
    return TimeStatusEnum.STARTED;
  }
}
